package offer;

/**
 * @Author SSK
 * @Date Created in 21:13 2019/8/6
 * @Description 字符流中第一个不重复的字符
 * @Version 1.0
 */
public class T55 {
    //Insert one char from stringstream
    public void Insert(char ch)
    {
        str.append(ch);
        vis[ch]++;
    }
    //return the first appearence once char in current stringstream
    public char FirstAppearingOnce()
    {
        while (index < str.length() ) {
            if (vis[str.charAt(index)]==1) {
                return str.charAt(index);
            }
            index ++ ;
        }
        return '#';
    }
    private int[] vis = new int[258];
    private StringBuilder str = new StringBuilder();
    private int index ;

}
